home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr24 / sdf21.zip / FLOP2.ASM next >
Assembly Source File  |  1993-05-20  |  12KB  |  245 lines

  1. TITLE        FLOP        6-16-87        [6-16-87]
  2. ;
  3. ; Modified by Jacques Pierson, Nov 4, 1987. Make program general,
  4. ; i.e. use INT 1Eh to point to Disk Base Parameters. Also change
  5. ; the values used for FAST, and alter motor stepping time.
  6. ; Reset disk system when done, to ensure new parms in effect.
  7. ;
  8. ;  Author  Rick Housh
  9. ;
  10. ;For PC's and compatibles
  11. ;
  12. ;SPEED UP YOUR FLOPPIES  -  Start doing it now.
  13. ;
  14. ;For reference, see the column "C Notes", by Joseph Katz in SEXTANT
  15. ;magazine, May-June, 1987, pp. 46-53, and the article "Faster Disk
  16. ;Access for Heath/Zenith MS-DOS", by Pat Swayne, REMark magazine,
  17. ;August, 1986.  Both those articles deal with the concept of this
  18. ;simple utility.
  19. ;
  20. ;This program, while originally written for Heath/Zenith PC compatible
  21. ;computers, should work with any IBM PC compatible, with ANY version
  22. ;of MS-DOS, with assembly by ANY version of MASM.
  23. ;
  24. ;Reconfigures floppy drives to modify the head settle times and
  25. ;wait for motor start set in ROM.  These original times have proved
  26. ;to be overly conservative for the latest half-height drives with locking
  27. ;latches, in which the heads are always engaged.
  28. ;
  29. ;Based on an original idea by Pat Swayne, modified and translated by me
  30. ;into Turbo Pascal, rewritten by Joseph Katz in 'C', and here translated
  31. ;back into assembly language for MASM.
  32. ;
  33. ;All higher language overhead has been removed here, and the medium speed
  34. ;has been modified slightly, to allow some head settle time.  Experience
  35. ;and testing have indicated that, while reducing the head settle time to
  36. ;zero has increased transfer rates, it has also increased the number of
  37. ;retries caused by read or write errors.  If that does not prove to be
  38. ;a problem, use FLOP FAST, otherwise use FLOP MEDIUM.  Almost never should
  39. ;FLOP SLOW be required.
  40. ;
  41. ;How will you know if you have an excessive number of retries?  Beats me!
  42. ;My Shugarts do, my Teacs don't.
  43. ;
  44. ;This is NOT a TSR (memory resident) program.  It patches (on the fly)
  45. ;the memory locations in which DOS holds the DBP (disk base parameters).
  46. ;Therefore, it can be run at any time and will effectuate the changes
  47. ;immediately.
  48. ;
  49. ;Typically, switching from FLOP SLOW to FLOP FAST will result in an increase
  50. ;in the data transfer rate of about 30%, a worthwhile gain.
  51. ;
  52. ;Actually, to be completely "well-behaved" this program should get the
  53. ;segment and offset addresses of the disk parameters through function
  54. ;35 (hex) of DOS interrupt 21 (hex), which would supply the vector to
  55. ;them, then use function 25 (hex) to reset the vectors to entirely new
  56. ;locations.
  57. ;
  58. ;Nevertheless, in the interests of speed and size, direct memory
  59. ;access is used herein, based on the assumption that Bill Gates and
  60. ;"Big Blue" will not decide to grace us all with a change, and the
  61. ;values in the original locations are simply "patched" with new values.
  62. ;"And God bless us all," said Tiny Tim.
  63. ;
  64. ;In his column Dr. Katz expressed some anxiety that many Turbo Pascal
  65. ;programmers might be in better physical condition than he, implying
  66. ;some apprehension that he might be in danger of abuse for criticizing
  67. ;someone's choice of language.  I, for one, am just a simple country lawyer,
  68. ;as deskbound as any college professor such as Dr. Katz, and have no intention
  69. ;of disputing his claims that C can produce more compact programs.  On the
  70. ;contrary, I agree.  What I do not agree with is that one needs a C shell
  71. ;simply for the purpose of calling a few assembly language routines.
  72. ;
  73. ;To those of you who are interested, because I was taken somewhat to
  74. ;task by Dr. Katz for my Turbo Pascal program, which occupied about
  75. ;12,000 bytes, while his 'C' program only used about 6,000, this assembly
  76. ;program, which performs almost exactly the same function, uses only 472
  77. ;bytes, less than one standard MS-DOS disk sector.
  78. ;
  79. ;How can that be, you say?
  80. ;
  81. ;Well, it has nothing in it that it doesn't use, while compilers have
  82. ;a lot of unused baggage.  Yes, Turbo Pascal has more than C.
  83. ;
  84. ;You get what you pay for (with your coding time) and compilers carry
  85. ;overhead.  This is a very small program, and should be written in
  86. ;assembly language.  I have done it here just to show the contrast.
  87. ;
  88. ;It could even be written in <UGH> BASIC and compiled, in which case it
  89. ;would need about 32,000 bytes.  (Think of all the unused "PLAY" and
  90. ;"SCREEN" and "Who-Knows-What-Else" code which is carried along, unused).
  91. ;
  92. ;It is the "#include <stdio.h>" in Dr. Katz' C program which carries the
  93. ;C baggage.  The equivalent code is automatically included in Turbo Pascal
  94. ;and Basic.  Assembly includes nothing you don't write yourself.
  95. ;
  96. ;If you are interested, access Compuserve, Heath Users Group, (GO PCS 48)
  97. ;and download my Turbo Pascal program DSKSPD.ARC, in addition to this
  98. ;program, FLOP.ARC.  I could not find Dr. Katz' program SPIN.C (mentioned in
  99. ;his SEXTANT column) there.  I guess you'll have to buy that issue.
  100. ;
  101. ;The whole schmear (SP?) is a good lesson in why you should learn assembly
  102. ;language.
  103. ;
  104. ;                            Rick Housh
  105. ;                            Compuserve PIN 72466,212
  106. ;                            MUG (Mission, KS. User's Group)
  107. ;                            BBS (913) 362-9583
  108. ;
  109. ;  My thanks to Tom Gilbert, President, MUG, (Mission, Kansas Users' Group),
  110. ;  whose course in assembly language made this possible for me.
  111. ;
  112. ;       Next is assembly code for FLOP.COM
  113. ;
  114. ;First, the equates:
  115. ;
  116. LF              equ     0Ah                     ;Line feed
  117. CR              equ     0Dh                     ;Carriage return
  118. BELL            equ     07h                     ;ASCII bell character ^G
  119. CMD_LINE        equ     80h                     ;Command line length location
  120. PARM_CHAR       equ     82h                     ;1st significant char in cmd ln
  121. ALT_PARM_CHAR   equ     83h                     ;2nd    "         "    "  "   "
  122.  
  123. ; offsets from Disk Base Parameters (pointed to by pseudo INT 1Eh) :
  124. Step_Rate    equ    0    ;first nibble => (16-value)* 2 ms
  125.                 ;Second nibble => head unload time
  126. HEAD_SETTLE     equ     9
  127. MOTOR_START     equ     10
  128.  
  129. SET_FLOPPIES        SEGMENT
  130.  
  131.       ASSUME DS:SET_FLOPPIES, SS:SET_FLOPPIES, CS:SET_FLOPPIES, ES:SET_FLOPPIES
  132.  
  133.         ORG        100h
  134. START:        jmp        INIT_GETPARMS
  135.  
  136. NOPARM_MSG         db      BELL,CR,'FLOP.COM by Rick Housh'
  137.            db       ', Enhanced by JP, Nov 87'
  138.                    db      CR,LF,'Optimizes floppy disk access times.'
  139.                    db      CR,LF,'You must enter a valid parameter.'
  140.                    db      CR,LF
  141.                    db      'Proper syntax is FLOP/Speed or FLOP Speed'
  142.                    db      ' where "Speed" is FAST,'
  143.                    db      CR,LF,'MEDIUM, NORMAL, or SLOW,'
  144.                    db      ' e.g., FLOP FAST, FLOP/FAST, FLOP F, or FLOP/F.'
  145.                    db      CR,LF,'Normal and Medium are the same.'
  146.                    db      ' Current settings not changed.'
  147.                    db      CR,LF,'$'
  148.  
  149. ;The next two db's are here only to allow you to get the above message printed
  150. ;to the screen when you enter TYPE FLOP.COM at the DOS prompt.
  151. ;FIXIT knocks out the $ sign and CTRL_Z makes the DOS TYPE command think it
  152. ;sees the end of a text file.  You may remove them and save three bytes if
  153. ;you don't care about that.
  154.  
  155. FIXIT              db      CR,' '
  156. CTRL_Z             db      1Ah
  157.  
  158. ;But don't remove the next four db's.  They are necessary messages.
  159.  
  160. FLOP_SET_MSG       db      CR,LF,'Floppies set to $'
  161. FAST_MSG           db      'fast.',CR,LF,'$'
  162. MEDIUM_MSG         db      'normal (medium).',CR,LF,'$'
  163. SLOW_MSG           db      'slow.',CR,LF,'$'
  164.  
  165.  
  166. INIT_GETPARMS:
  167. ;
  168. ;  We're going to fudge quite a bit here, in the interest of saving space.
  169. ;  We should throw away leading spaces and other junk, but won't.
  170. ;  We'll allow just one extra character at beginning of param line.
  171. ;  The worst that will happen is a "no parameter" message.
  172. ;
  173.         mov     AH,[CS:CMD_LINE]                ;Get # of chars in param string
  174.         cmp     AH,02h                          ;Are there less than two?
  175.         jb      ERROR_EXIT                      ;Then not enough. Exit
  176.         mov     AL,[CS:PARM_CHAR]               ;Get second char in param line
  177.         cmp     AL,'/'                          ;Is it a slash?
  178.         jnz     NOT_SLASH                       ;No? Then read it.
  179.         mov     AL,[CS:ALT_PARM_CHAR]           ;Yes? Then read third.
  180. NOT_SLASH:
  181.         cmp     AL,'f'                          ;Is 1st char less than 'f'?
  182.                                                 ;e.g., upper case?
  183.         jb      CONTINUE                        ;Yes? Then use it.
  184.         sub     AL,20h                          ;Else make upper case.
  185. CONTINUE:
  186.         cmp     AL,'S'                          ;Is it 'Slow'
  187.         jz      DO_SLOW                         ;Yes?  Then make floppies slow
  188.         cmp     AL,'N'                          ;Is it 'Normal'?
  189.         jz      DO_MEDIUM                        ;Yes? Then same as Medium
  190.         cmp     AL,'M'                          ;Is it 'Medium'?
  191.         jz      DO_MEDIUM                       ;Yes?  Then set floppies medium
  192.         cmp     AL,'F'                          ;Is it  'Fast'? (Last option)
  193.         jnz     ERROR_EXIT                      ;Yes?  Then just fall through
  194.                                                 ;else go to error exit.
  195. DO_FAST:                                        ;If going to fast floppies
  196.         mov     BH,00h                          ;Set head settle for 0 msec.
  197.         mov     BL,00h                          ;and motor start wait for 0 ms
  198.     mov    cl,0e0h                ;4 ms step rate, no head unload
  199.         mov     DX,OFFSET FAST_MSG              ;Get ready to print message
  200.         jmp     SET_SPEED                       ;and do it.
  201. DO_MEDIUM:                                      ;If going to medium
  202.         mov     BH,01h                          ;Head settle at 1 msec.
  203.         mov     BL,02h                          ;Mtr start wait at 250msec.
  204.     mov    cl,0dfh                ;6 ms step rate, head unload
  205.         mov     DX,OFFSET MEDIUM_MSG            ;Get ready to print message
  206.         jmp     SET_SPEED                       ;and do it.
  207. DO_SLOW:
  208.         mov     BH,0Dh                          ;Slow head settle is 13 msec!
  209.         mov     BL,08h                          ;and mtr start wait is 1 sec!
  210.     mov    cl,0fh                ;32 ms step rate, head unload
  211.         mov     DX,OFFSET SLOW_MSG              ;No other possibility here
  212.                                                 ;so just fall through.
  213. SET_SPEED:
  214.         push    DX                              ;Save floppy speed msg ptr
  215.         mov     AH,09h                          ;Set for print string function
  216.         mov     DX,OFFSET FLOP_SET_MSG          ;for "Floppies set to "
  217.         int     21h                             ;and call DOS
  218.         push    BP                              ;Save BP
  219.         mov     BP,SP                           ;Move SP to BP
  220.         push    ES                              ;Save Extra Segment
  221.     xor    ax,ax                ;Point to Int vectors
  222.     mov    es,ax                ;to ES
  223.     mov    ax,bx                ;save values in AX
  224.     les    bx,dword ptr es:(1Eh*4)        ;get DBP address
  225.     mov    byte ptr es:[bx + Step_Rate],cl
  226.         mov     BYTE PTR ES:[bx + HEAD_SETTLE],ah ;Head settle time
  227.         mov     BYTE PTR ES:[bx + MOTOR_START],al ;and Motor start time
  228.         pop     ES                              ;Restore ES
  229.         pop     BP                              ;and BP
  230.         pop     DX                              ;Get speed message ptr
  231.     mov    ah,0
  232.     int    13h                ;reset disk system
  233.         jmp     FINIS
  234. ERROR_EXIT:
  235.         mov     DX,OFFSET NOPARM_MSG            ;Set ptr to info-error message
  236. FINIS:
  237.         mov     AH,09h                          ;and
  238.         int     21h                             ;print the message at DX,
  239.     mov    ax,4C00h            ;terminate w/return code 0
  240.     int    21h
  241.     
  242.         SET_FLOPPIES        ENDS
  243. ;
  244. END        START
  245.